#include <iostream>
using namespace std;
#include <cstring>

/*
	this指针：
		对象指针: 指向当前对象
		当形式参数的名字和类的属性名重名时，用来解决不能访问类的成员属性
		this指针不能修改指向
		类的成员函数都包含一个隐士this指针，并且位于第一个参数位置.
		静态函数/全局函数没有this指针
		
*/
class Student{
private:
	int		id;
	char 	name[20];
	double 	score;
public:
	Student(int id, const char* name, double score);
	//get set ...

	//void display(Student* const this);
	void display();			//隐士参数this指针.
};

Student::Student(int id, const char* _name, double score)
	:id(id), score(score)
{	
	//this->id = id;
	//this->score = score;
	strcpy(this->name, _name);
}


void Student::display()
{
	cout << "this: " << this << endl;
	Student tony(2, "tony", 90);
	//this = &tony;			//error
	cout << "id: " << this->id << endl;
	cout << "name: " << this->name << endl;
	cout << "score: " << this->score << endl;
}


int main(int argc, char**argv)
{
	Student tom(1, "tom", 89.6);		//Student tom = Student(1, "tom", 89.6);
	tom.display();
	cout << "&tom" << &tom << endl;
	//display(&tom);

	return 0;
}
